﻿using CSharpDesign.DAL;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace CSharpDesign.BLL
{
    public class MMPwdService
    {
        SqlHelper data = new SqlHelper();
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userid">用户id</param>
        /// <param name="textpwd1">原密码</param>
        /// <param name="Username">用户名</param>
        /// <param name="txtpwd">修改后密码</param>
        public void chkpwds(string userid, string textpwd1, string Username, string txtpwd)
        {
            SqlDataReader dr = data.GetDataReader("select * from  Users  where id='" + userid + "' and pwd='" + textpwd1 + "'");
            if (dr.Read())
            {
                SqlHelper mydata = new SqlHelper();
                try
                {
                    string sql = "update [Users]  set [pwd] ='" + txtpwd + "' where [id]='" + Username + "' ";
                    mydata.RunSql(sql);
                }
                catch
                {
                    throw new Exception("修改失败！");
                }
            }
            else
            {
                throw new Exception("原密码不正确!");
            }
        }
    }
}